package top.tagao.yygh.common.utils;

import top.tagao.yygh.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取当前用户信息工具类
 * @author fu-xiao-liu
 * @Date 2022/3/12 11:18
 */
public class AuthContextHolder {


    /**
     * @date  获取当前用户Id
     * @return null
     */
    public static Long getUserID(HttpServletRequest request){
        String token = request.getHeader("token");
        return JwtHelper.getUserId(token);
    }

    /**
     * @date  获取当前用户名称
     * @param request
     * @return java.lang.String
     */
    public static String getUserName(HttpServletRequest request){
        String token = request.getHeader("token");
        return JwtHelper.getUserName(token);
    }
}
